#ifndef __H_MVP_COMPONENT_H__
#define __H_MVP_COMPONENT_H__

#include <chrono>

#include "node/node.h"

namespace motovis
{

class Component
{
public:
    Component(const std::string& component_name="");
    virtual ~Component();

protected:
    /**
     * @brief sub class process business logic here
     */
    virtual void Proc() = 0;

    /**
     * @brief start component main task
     * @param process_period main task processing period
     * @param affinity main task cpu affinity
     * @param priority main task priority
     */
    void StartMainTask(const std::chrono::milliseconds& process_period,
                const int affinity = -1,
                const int priority = -1);

    std::unique_ptr<Node> node_;

private:
    void Exec();
    std::shared_ptr<std::thread> task_;
    std::string name_;
    std::chrono::milliseconds period_;
    int affinity_;
    int priority_;
};

} // namespace motovis

#endif // __H_MVP_COMPONENT_H__
